<template>
	<view class="content">
		  <view class="order" >
			<view class="dao" @click="url" data-url="/pages/user/info" data-id="1">
				<image src="../../static/images/icon20.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">我的资料</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="zhuxiao">
				<image src="../../static/images/icon21.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">注销账号</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="url" data-url="/pages/user/danye?id=1">
				<image src="../../static/images/icon28.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">用户协议</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="url" data-url="/pages/user/danye?id=2">
				<image src="../../static/images/icon27.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">隐私政策</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="url" v-if="uid>0" data-url="/pages/user/yijian">
				<image src="../../static/images/icon26.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">意见反馈</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="url" v-if="uid>0" data-url="/pages/user/heimingdan">
				<image src="../../static/images/heimingdan.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">黑名单</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="tuichu" v-if="uid>0">
				<image src="../../static/images/icon23.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">安全退出</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<!--  #ifdef  APP-PLUS -->
			<view class="dao" @click="huancun">
				<image src="../../static/images/icon22.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">清除缓存<text>{{huancun_size}}</text></view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<!--  #endif -->
		  </view>
		  
	</view>
</template>

<script>
	var app=getApp();
	export default {
		data() {
			return {
				uid:0,
				huancun_size:0
			}
		},
		onLoad() {
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==false){
				this.uid=uid;
			}
			// #ifdef  APP-PLUS
			this.gethuancun();
			// #endif
			
		},
		methods: {
			tuichu(){
				uni.showModal({
				    title: '您确定需要退出账号吗？',
				    success: function (res) {
				        if (res.confirm) {
				            uni.removeStorageSync('uid');
				            uni.navigateBack({
				                delta: 1
				            });
				        }
				    }
				});
			},
			zhuxiao(){
				const uid = uni.getStorageSync('uid');
				if(app.isBlank(uid)==true){
					uni.navigateTo({
					    url: '/pages/login/login'
					});
					return false;
				}
				var that=this;
				uni.showModal({
				    content: '注销账号后，账号里所有的信息和服务将会被删除，不可恢复，确定要注销吗？',
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				                title: '注销中'
				            });
				            uni.request({
				                url: app.globalData.url+"user/zhuxiao",
				            	method:"POST",
				            	dataType:"json",
				            	header: {
				            	    'content-type': 'application/x-www-form-urlencoded'
				            	},
				                data: {uid:uid},
				                success: (res) => {
				            		uni.hideLoading();
				            		if(res.data.code!=1){
				            			uni.showToast({
				            			    title: res.data.msg,
				            				icon:'none',
				            			    duration: 1500
				            			});
				            			return false;
				            		}
				            		uni.showToast({
				            		    title: res.data.msg,
				            			icon:'success',
				            		    duration: 1000
				            		});
									setTimeout(function(){
										uni.removeStorageSync('uid');
										uni.reLaunch({
										    url: '/pages/index/index'
										});
									},1000)
				                }
				            });
				        }
				    }
				});
			},
			url(e){
				var url=e.currentTarget.dataset.url;
				var id=e.currentTarget.dataset.id;
				const uid = uni.getStorageSync('uid');
				if(app.isBlank(uid)==true && id==1){
					uni.navigateTo({
					    url: '/pages/login/login'
					});
					return false;
				}
				uni.navigateTo({
				    url: url
				});
			},
			gethuancun(){
				var self=0;
				var that=this;
				plus.cache.calculate( function ( size ) { //size是多少个字节单位是b
					 //你可以做下面相应的处理
					 if(size<1024){
						 self=size+'B'; 
					 }  
					 else if(size/1024>=1 && size/1024/1024<1){
						  self= Math.floor(size/1024*100)/100+'KB';
					 }
					else if(size/1024/1024>=1){
						 self=Math.floor(size/1024/1024*100)/100+'M';
					}
					that.huancun_size=self;
				});
			},
			huancun(){
				var that=this;
				uni.showModal({
					title:'清除缓存',
					content:'有'+that.huancun_size+'缓存可清理，是否清理?',
					confirmText:'清除',
					success(res) {
						if(res.confirm){
							plus.cache.clear( function () {
								uni.showToast({
									title:'清除成功',
									icon:'success',
									success() {
										//成功后处理
										that.huancun_size="0B";
									}
								})
							});	
						}
					}
				})
			}
		}
	}
</script>

<style>
	.dao2 text{color:red;float: right;margin-right: 5px;}
	.order .dao:last-child{margin-bottom: 10px;}
	.tubiao2{width:20px;height:20px;margin-top: 10px;}
	.dao2{width:100%;height:40px;line-height: 40px;flex:1;font-size: 0.9rem;}
	.tubiao{width:20px;height:20px;margin-top: 10px;margin-right: 8px;}
	.dao{width:94%;padding: 3px 3%;display: flex;height:40px;border-bottom:1px rgb(245, 245, 245) solid;}
	.kefu5{width:40px;height:20px;line-height: 20px;border-radius:5px;text-align: center;margin-top: 10px;border:1px #999 solid;color:#999;font-size: 0.8rem;margin-left: 5px;}
	.kefu4{width:100%;height:40px;line-height: 40px;flex: 1;overflow: hidden;}
	.kefu3 image{width:25px;margin-top: 7.5px;margin-right: 10px;}
	.kefu3{width:94%;padding: 0px 3%;height:40px;display: flex;margin-top: 10px;}
	.chazi{width:40px;height:40px;position: absolute;bottom: -50px;z-index: 9999;left: 50%;margin-left: -20px;}
	.kefu2{width:250px;height:160px;background-color: #fff;position: fixed;top:50%;margin-top: -80px;left: 50%;margin-left: -125px;border-radius: 5px;z-index: 9999;}
	.kefu{width:100%;height:100vh;position: fixed;top:0px;z-index: 9999;background-color: #000000;opacity: 0.7;}
	.user5-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user5-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user5-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user3-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user3-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user3-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user4-1{width:1px;height:70px;background-color: rgb(245, 245, 245);margin: 0 auto;}
	.user5{width:49.5%;height:70px;float: left;}
	.user4{width:1%;height:70px;float: left;text-align: center;}
	.user3{width:49.5%;height:70px;float: left;}
	.user2{width:96%;padding: 10px 2%;overflow: hidden;}
	
	.header{width:100%;height:100px;background-color:#05c160;position: relative;}
	.header_1{width:100%;height:100px;overflow: hidden;}
	.avatar{width:25%;float: left;text-align: center;height:100px;}
	.avatar image{width:70px;margin-top: 15px;border-radius: 50%;height:70px;}
	.nickname{width:70%;float: left;height:100px;}
	.nick{width:100%;height:35px;line-height: 35px;margin-top: 15px;font-size: 1.1rem;color:#fff;overflow: hidden;}
	.level{width:100px;height:20px;line-height: 20px;border:1px #fff solid;text-align: center;color:#fff;border-radius: 20px;font-size: 0.7rem;margin-top: 5px;}
	.site{width:15%;float: left;height:100px;text-align: center;}
	.site image{width:25px;margin-top: 15px;}
	.bai{width:100%;height:50px;background-color: #fff;opacity: 0.15;position: absolute;bottom: 0px;}
	.yue{width:100%;height:50px;position: absolute;bottom: 0px;overflow: hidden;}
	.money{width:33.33%;float: left;}
	.money_1{width:100%;text-align: center;height:25px;line-height: 30px;font-size: 1.1rem;color:#fff;margin-top: 1px;}
	.money_2{width:100%;text-align: center;height:20px;line-height: 20px;color:#fff;}
	
	.zhong{width:100%;padding: 15px 0px;overflow: hidden;}
	.zhong_1{width:49%;float: left;overflow: hidden;}
	.level_img{width:40%;float: left;text-align: right;}
	.level_img image{width:40px;margin-right: 10px;}
	.level_title{width:60%;float: left;}
	.user_c{width:100%;height:22px;line-height: 28px;color:#f08a04;font-size: 0.9rem;overflow: hidden;}
	.shuo{width:100%;height:18px;line-height: 22px;color:#999;font-size: 0.6rem;overflow: hidden;}
	
	.user_c2{width:100%;height:22px;line-height: 28px;color:#666;font-size: 0.9rem;overflow: hidden;}
	.zhong_2{width:2%;float: left;text-align: center;}
	.zhong_2 view{width:1px;height:40px;background-color: #eee;}
	.zhong_3{width:49%;float: left;}
	.advert{width:96%;padding: 8px 2%;background-color: rgb(245, 245, 245);}
	.advert image{width:100%;border-radius: 20px;}
	
	.order{width:100%;}
	.order_1{width:96%;padding: 0px 2%;overflow: hidden;border-bottom: 1px rgb(245, 245, 245) solid;}
	.order_1_1{width:50%;height:40px;line-height: 40px;font-size: 1rem;float: left;color:#333;font-weight: 600;}
	.order_1_2{width:50%;height:40px;float: left;overflow: hidden;}
	.order_1_2 image{width:16px;margin-top:12px;float: right;}
	.order_1_2 text{line-height: 40px;float: right;color:#999;}
	
	.order_2{width:100%;overflow: hidden;padding: 12px 0px;}
	.status{width:33.33%;float: left;position: relative;display: block;}
	.status_1{width:100%;text-align: center;}
	.status_1 image{width:60px;}
	.status_2{width:100%;height:22px;line-height: 22px;color:#666;text-align: center;font-size: 0.9rem;}
	.count{border:1px #f36 solid;border-radius: 15px;padding: 0px 5px;line-height: 15px;position: absolute;top:-5px;font-size: 0.6rem;color:#f36;z-index: 9999;right:16%;background-color: #fff;}
	.fenge{width:100%;height:6px;background-color: rgb(245, 245, 245);}
	
	.tui_goods{width:96%;padding-left: 2%;padding-right: 2%;overflow: hidden;margin-top: 15px;}
	.tui_goods_1{width:50%;float: left;margin-bottom: 10px;}
	.tui_goods_1_1{width:98%;}
	.tui_goods_1_1 image{width:100%;border-radius: 5px;}
	.tui_title{width:100%;height:25px;line-height: 25px;color:#666;overflow:hidden;text-overflow: ellipsis;white-space: nowrap; }
	.tui_price{width:100%;height:25px;line-height: 25px;color:#f36;}
	.tui_goods_1:nth-of-type(even) .tui_goods_1_1{float: right;}
	.tui_price text{font-size: 0.7rem;color:#999;float: right;}
	
	.mingcheng{width:100%;overflow: hidden;margin-top:10px;}
	.mc_1{width:35%;height:22px;line-height: 22px;float: left;color:#666;text-align: right;}
	.mc_2{width:30%;height:22px;line-height: 22px;float: left;color:#666;text-align: center;font-size: 0.9rem;}
	.mc_3{width:35%;height:22px;line-height: 22px;float: left;color:#666;text-align: left;}
	
	.mc_1 view{width:60%;height:1px;background-color: #666;margin-top: 11px;float: right;}
	
	.mc_3 view{width:60%;height:1px;background-color: #666;margin-top: 11px;float: left;}
	.mc_1 text{float: right;margin-left: 5px;}
	.mc_3 text{float: left;margin-right: 5px;}
</style>
